{$wrapper_prefix|default}

<section class="hbox stretch">
    <aside class="aside-md bg-white b-r">
        <section class="vbox">
            <header class="b-b header">
                <p class="h4">{if $user}编辑用户{else}添加用户{/if}</p>
            </header>

            <section class="scrollable wrapper w-f">
                <form class="form-horizontal" id="edit_form" action="/admin/user/add" method="post">
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">{if ! $userid}<font class="red">* </font>{/if}用户名</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control {if $userid}disabled{/if}" id="username" name="username" value="{$user.username}" placeholder="请输入用户名" {if $userid}readonly="readonly"{/if} />
                        </div>
                        <div class="col-sm-6">
                            <p class="form-control-static">{if $userid}编辑状态下，用户名不可以更改{/if}</p>
                        </div>
                    </div>
                    <div class="line line-dashed line-lg pull-in"></div>

                    <div class="form-group">
                        <label for="password" class="col-sm-2 control-label">{if ! $userid}<font class="red">* </font>{/if}密码</label>
                        <div class="col-sm-4">
                            <input type="password" class="form-control" id="password" name="password" value="" />
                        </div>
                        <div class="col-sm-6">
                            <p class="form-control-static">{if $userid}不修改请不要填写{/if}</p>
                        </div>
                    </div>
                    <div class="line line-dashed line-lg pull-in"></div>

                    <div class="form-group">
                        <label for="fullname" class="col-sm-2 control-label">全名</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="fullname" name="fullname" value="{$user.fullname}" placeholder="请输入全名" />
                        </div>
                    </div>
                    <div class="line line-dashed line-lg pull-in"></div>

                    <div class="hide">
                        <div class="form-group">
                            <label for="nickname" class="col-sm-2 control-label">昵称</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="nickname" name="nickname" value="{$user.nickname}" placeholder="请输入昵称" />
                            </div>
                        </div>
                        <div class="line line-dashed line-lg pull-in"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-4">
                                <label class="checkbox-inline p-left-0">
                                    <input type="radio" name="gender" value="1" {if $user.gender eq 1}checked="checked"{/if} />&nbsp;男
                                </label>
                                <label class="checkbox-inline">
                                    <input type="radio" name="gender" value="2" {if $user.gender eq 2}checked="checked"{/if} />&nbsp;女
                                </label>
                            </div>
                        </div>
                        <div class="line line-dashed line-lg pull-in"></div>

                        <div class="form-group">
                            <label for="idcard" class="col-sm-2 control-label">身份证</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="idcard" name="idcard" value="{$user.idcard}" placeholder="请输入身份证" />
                            </div>
                        </div>
                        <div class="line line-dashed line-lg pull-in"></div>

                        <div class="form-group">
                            <label for="email" class="col-sm-2 control-label">E-mail</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="email" name="email" value="{$user.email}" placeholder="请输入电子邮箱" />
                            </div>
                        </div>
                        <div class="line line-dashed line-lg pull-in"></div>
                    </div>

                    {if ! $user || $user.userid > 1}
                    <div class="form-group">
                        <label class="col-sm-2 control-label">状态</label>
                        <div class="col-sm-4">
                            <label class="checkbox-inline p-left-0">
                                <input type="radio" name="status" value="0" {if $user.status eq 0}checked="checked"{/if} />&nbsp;未激活
                            </label>
                            <label class="checkbox-inline">
                                <input type="radio" name="status" value="1" {if $user.status eq 1}checked="checked"{/if} />&nbsp;已激活
                            </label>
                        </div>
                    </div>
                    <div class="line line-dashed line-lg pull-in"></div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">用户组</label>
                        <div class="col-sm-3">
                            <select name="groups" class="form-control">
                                {foreach from=$groups item=v}
                                <option value="{$v.groupid}" {if $v.groupid|in_array:$user_groupids}selected="selected"{/if}>{$v.groupname}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="line line-dashed line-lg pull-in"></div>

                    <div class="form-group default-hidden" id="setting_exptime">
                        <label class="col-sm-2 control-label"><font class="red">* </font>设置有效期</label>
                        <div class="col-sm-3">
                            <input name="exptime" class="form-control datetimepicker-input" type="text" autocomplete="off"
                                   data-date-format="yyyy-mm-dd hh:ii" value="{$user.exptime}" placeholder="点击选择行设置有效期"/>
                        </div>
                    </div>
                    {/if}

                    <div class="form-group" style="height:200px;"></div>

                    <input type="hidden" name="userid" value="{$user.userid}" />
                    <input type="hidden" name="salt" value="{$user.salt|escape}" />
                </form>
            </section>

            <footer class="footer b-t bg-white-only">
                <div class="m-t-sm">
                    <button type="button" id="submit_save_back" class="btn btn-s-md btn-primary btn-sm input-submit">保存</button>
                    {if ! $user}<button type="button" id="submit_save_continue" class="btn btn-s-md btn-primary btn-sm input-submit">保存并继续添加</button>{/if}
                    <button type="button" id="submit_cancel" class="btn btn-danger btn-sm input-submit">取消</button>
                    <span id="edit_notice"></span>
                </div>
            </footer>
        </section>
    </aside>
</section>

<!-- Datetimepicker -->
<link href="{$_STATIC_CDN}/scripts/datetimepicker/css/bootstrap-datetimepicker.css" rel="stylesheet" type="text/css"/>
<script src="{$_STATIC_CDN}/scripts/datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<script src="{$_STATIC_CDN}/scripts/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>

<script src="{$_STATIC_URL}/admin/js/user.edit.js" type="text/javascript"></script>


<!-- {literal} -->
<script type="text/javascript">
    /**
     * 设置有效期时，页面自动滚动到最底部
     */
    $('input[name=exptime]:last').on('focus', function(){
        var ele = $('#edit_form').parent();
        ele.scrollTop(5000, 0);
    });
</script>
<!-- {/literal} -->

{$wrapper_suffix|default}